package com.ant.storage.controller;

import com.ant.storage.common.ResultPage;
import com.ant.storage.pojo.AllocationWarehouseEnter;
import com.ant.storage.service.IAllocationWarehouseEnterService;
import com.ant.storage.common.PageRecv;
import com.ant.storage.common.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/allocationWarehouseEnter")
@Api(tags = "调拨入库接口")
public class AllocationWarehouseEnterController {

    @Autowired
    IAllocationWarehouseEnterService allocationWarehouseEnterService;

    @ApiOperation(value = "调拨入库单查询")
    @PostMapping("/queryAllocationWarehouseEnter")
    public ResultPage queryAllocationWarehouseEnter(@RequestBody PageRecv<AllocationWarehouseEnter> pageRecv){
        return allocationWarehouseEnterService.queryAllocationWarehouseEnter(pageRecv);
    }

    @ApiOperation(value = "调拨入库单编辑")
    @PostMapping("/allocationWarehouseEnterEdit")
    public ResultVo allocationWarehouseEnterEdit(@RequestBody AllocationWarehouseEnter allocationWarehouseEnter){
        return allocationWarehouseEnterService.allocationWarehouseEnterEdit(allocationWarehouseEnter,2);
    }

    @ApiOperation(value = "调拨入库单确认入库")
    @PostMapping("/allocationWarehouseEnterConfirm")
    public ResultVo allocationWarehouseEnterConfirm(@RequestBody AllocationWarehouseEnter allocationWarehouseEnter){
        allocationWarehouseEnterService.allocationWarehouseEnterEdit(allocationWarehouseEnter,3);
        //库存增加
        allocationWarehouseEnterService.stockAdd(allocationWarehouseEnter);
        return ResultVo.success("ok");
    }
}
